<!doctype html>
<html>
  <head>
    <meta charset="utf-8">
    <title>Point Hit Test</title>
    <link rel="stylesheet" href="../include/style.css">
  </head>
  <body>
    <header>
      Example from <a href="http://amzn.com/1430236655?tag=html5anim-20"><em>Foundation HTML5 Animation with JavaScript</em></a>
    </header>
    <canvas id="canvas" width="400" height="400"></canvas>
    <textarea id="log"></textarea>
    <aside>Move mouse over circle.</aside>

    <script src="../include/utils.js"></script>
    <script src="./classes/ball.js"></script>
    <script>
    window.onload = function () {
      var canvas = document.getElementById('canvas'),
          context = canvas.getContext('2d'),
          mouse = utils.captureMouse(canvas),
          log = document.getElementById('log'),
          ball = new Ball();

      ball.x = canvas.width / 2;
      ball.y = canvas.height / 2;
      ball.draw(context);

      canvas.addEventListener('mousemove', function () {
        if (utils.containsPoint(ball.getBounds(), mouse.x, mouse.y)) {
          log.value = "Hit!";
        } else {
          log.value = '';
        }
      }, false);
    };
    </script>
  </body>
</html>
